<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>商品咨询列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->
    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;" method="post">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                   <span>
                                       咨询日期：<input id='startDate' name='startDate' value="<!--{$startDate}-->" type='text' size="10" readonly >
                                        ～
                                        <input id='endDate' name='endDate' type='text'  size=10 value="<!--{$endDate}-->" readonly>
                                   </span>
                                   <span>
                                       商品名称：<input style="width:180px;" type="text" value="<!--{$goodsName}-->" autocomplete="off" maxlength="100" id="goodsName" name="goodsName">
                                   </span>
                                   <span>
                                       处理状态：<select id="consultStatus" name="consultStatus">
                                           <option value="">请选择</option>
                                           <option value="0">未处理</option>
                                           <option value="1">已处理</option>
                                       </select>
                                   </span>
                                   <span>
                                       网站显示控制：<select id="displayFlg" name="displayFlg">
                                           <option value="">请选择</option>
                                           <option value="0">仅咨询人可见 </option>
                                           <option value="1">所有人可见</option>
                                       </select>
                                   </span>
                                   <span><input type="button" value="查询" class="btn" onclick="goodsConsult.search();" /></span>
                                   <span><input type="button" name="export" id="export" class="btn" value="商品咨询导出" style="width:110px;height:27px;" onclick="goodsConsult.consultExport();"></span>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/content/goodsConsult.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 80, align: "center"},
            {display: "商品名称", width : 230},
            {display: "咨询内容", width : 230},
            {display: "咨询时间", name : "createTime", width : 150, align: "center", sortable : true},
            {display: "网站用户名", width : 150},
            {display: "回复时间", width : 150},
            {display: "回复人", width : 100},
            {display: "处理状态", width : 70}
        ],
        buttons : [
            {name: "删除", bclass: "delete", onpress : "goodsConsult.deleteGoodsConsult"}
        ],
        sortname: "createTime",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var goodsConsult = {

        delete_str: "",

        //查询
        search: function () {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //重新加载页面内容
        load: function() {
            $("#flex").flexReload();
        },

        //咨询处理
        deal: function (consult_uuid) {
            E.open("/quanliadmin/app/content/goodsConsult.pscript?operFlg=2&uuid=" + consult_uuid);
        },

        //咨询删除
        deleteGoodsConsult: function() {
            this.delete_str = "";
            $.each($("#flex").find("tr"), function(k, v) {
                if ($(v).hasClass("trSelected")) {
                    goodsConsult.delete_str += "_" + $(v).attr("id").replace("row", "");
                }
            });

            if (this.delete_str == "")
                E.alert("请选择删除商品咨询");
            else
                E.confirm("您确认要删除选中的商品咨询吗？", "goodsConsult.deleteConfirm");
        },

        deleteConfirm: function() {
            this.delete_str = this.delete_str.substr(1);
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/content/goodsConsult.ajax?operFlg=2&delete_str=" + goodsConsult.delete_str,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "goodsConsult.load");
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //商品咨询导出
        consultExport: function(){
            var formValue = document.getElementById("search_form");
            var startDate = $('#startDate').val();
            var endDate = $('#endDate').val();
            var consultStatus = $('#consultStatus').val();
            var displayFlg = $('#displayFlg').val();
            var goodsName = $('#goodsName').val();
            formValue.action = "/quanliadmin/app/content/goodsConsult.pscript?operFlg=3&startDate=12&endDate=12&consultStatus=12&displayFlg=11&goodsName=12";
            formValue.submit();
        }
    };

    $('#startDate').datetimepicker();
    $('#endDate').datetimepicker();

    init_search_suggestion(document.getElementById('goodsName'),1);
    var  error="<!--{$error_msg}-->";
    if(error !="")
        comm_alert(error,0);

</script>

</body>
</html>